package com.alipay.demo.controller;

import com.alipay.demo.entity.CallbackClazz;
import com.alipay.demo.entity.NotifyClazz;
import com.alipay.demo.entity.OrderClazz;
import com.alipay.demo.service.IAliPayService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: zhuzhiping
 * @description:
 * @date: 2021/1/6 15:20
 */

@RestController
@Slf4j
public class AliPayController {

    @Autowired
    private IAliPayService aliPayService;

    @PostMapping("/pay")
    public String pay(@RequestBody OrderClazz orderClazz) {
        String rsp = aliPayService.pay(orderClazz);
        return rsp;
    }

    @GetMapping("/pay/callback")
    public String payCallback(CallbackClazz callbackClazz) throws Exception {
        String rsp = aliPayService.payCallback(callbackClazz);
        return rsp;
    }

    @PostMapping("/pay/notify")
    public String payNotify(NotifyClazz notifyClazz) throws Exception {
        String rsp = aliPayService.payNotify(notifyClazz);
        return rsp;
    }

    @PostMapping("/pay/query")
    public String payQuery(@RequestBody OrderClazz orderClazz) throws Exception {
        String rsp = aliPayService.payQuery(orderClazz);
        return rsp;
    }

    @PostMapping("/pay/refund")
    public String payRefund(@RequestBody OrderClazz orderClazz) throws Exception {
        String rsp = aliPayService.payRefund(orderClazz);
        return rsp;
    }

    @PostMapping("/pay/refund/query")
    public String payRefundQuery(@RequestBody OrderClazz orderClazz) throws Exception {
        String rsp = aliPayService.payRefundQuery(orderClazz);
        return rsp;
    }


    @PostMapping("/pay/close")
    public String payClose(@RequestBody OrderClazz orderClazz) throws Exception {
        String rsp = aliPayService.payClose(orderClazz);
        return rsp;
    }
}
